package com.net.service.impl;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import com.net.dao.CommodityDao;
import com.net.model.Commodity;
import com.net.service.CommodityService;
@Component("commodityService")
public class CommodityServiceImpl implements CommodityService {
	private CommodityDao commodityDao ;

	public void add(Commodity u) throws Exception {
		commodityDao.save(u);
	}

	public boolean delete(Commodity u) {
		return commodityDao.delete(u);
	}

	public List<Commodity> getCommodities() throws Exception {
		return commodityDao.getCommodities();
	}

	public Commodity loadCommodityByName(String name) throws Exception {
		return commodityDao.loadCommodityByName(name);
	}

	public Commodity loadCommodityById(int id) {
		return commodityDao.loadCommodityById(id);
	}

	public CommodityDao getCommodityDao() {
		return commodityDao;
	}
	@Resource(name="commodityDao")
	public void setCommodityDao(CommodityDao commodityDao) {
		this.commodityDao = commodityDao;
	}

	public void update(Commodity commodity) {
		this.commodityDao.update(commodity);
	}

	public List<Commodity> searchList(Commodity commodity) {
		return commodityDao.searchList(commodity);
	}

	public List<Commodity> getCommodities(int currentPage, int perPage,
			String orderType, String orderName) {
		return commodityDao.getCommodities(currentPage, perPage, orderType, orderName);
	}

	public List<Commodity> getCommoditiesByCondition(int currentPage,
			int perPage, String condition) {
		return commodityDao.getCommoditiesByCondition(currentPage, perPage, condition);
	}

	public int getCount() {
		return commodityDao.getCount();
	}
}
